package com.ruoyi.comprehensive.service.impl;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.comprehensive.mapper.DrawingMapper;
import com.ruoyi.comprehensive.domain.Drawing;
import com.ruoyi.comprehensive.service.IDrawingService;


/**
 * 图纸管理Service业务层处理
 * 
 * @author hcc
 * @date 2023-12-12
 */
@Service
public class DrawingServiceImpl implements IDrawingService 
{
    @Autowired
    private DrawingMapper drawingMapper;

    /**
     * 查询图纸管理
     * 
     * @param id 图纸管理主键
     * @return 图纸管理
     */
    @Override
    public Drawing selectDrawingById(Long id)
    {
        return drawingMapper.selectDrawingById(id);
    }

    /**
     * 查询图纸管理列表
     * 
     * @param drawing 图纸管理
     * @return 图纸管理
     */
    @Override
    public List<Drawing> selectDrawingList(Drawing drawing)
    {
        return drawingMapper.selectDrawingList(drawing);
    }

    /**
     * 新增图纸管理
     * 
     * @param drawing 图纸管理
     * @return 结果
     */
    @Override
    public int insertDrawing(Drawing drawing)
    {
        Drawing drawing1 = new Drawing();
        BeanUtils.copyProperties(drawing,drawing1);
        drawing1.setCreateByName(SecurityUtils.getUsername());
        drawing1.setCreateAt(new Date());
        drawing1.setCreateBy(SecurityUtils.getUserId().toString());
        drawing1.setVersionNo("1");
        if (drawing1.getTypeId()=="1"){
            drawing1.setTypeName("专业类型1");
        }else if (drawing1.getTypeId()=="2"){
            drawing1.setTypeName("专业类型2");
        }else if (drawing1.getTypeId()=="3"){
            drawing1.setTypeName("专业类型3");
        }else {
            drawing1.setTypeName(null);
        }
        return drawingMapper.insertDrawing(drawing1);
    }

    /**
     * 修改图纸管理
     * 
     * @param drawing 图纸管理
     * @return 结果
     */
    @Override
    public int updateDrawing(Drawing drawing)
    {
        return drawingMapper.updateDrawing(drawing);
    }

    /**
     * 批量删除图纸管理
     * 
     * @param ids 需要删除的图纸管理主键
     * @return 结果
     */
    @Override
    public int deleteDrawingByIds(Long[] ids)
    {
        return drawingMapper.deleteDrawingByIds(ids);
    }

    /**
     * 删除图纸管理信息
     * 
     * @param id 图纸管理主键
     * @return 结果
     */
    @Override
    public int deleteDrawingById(Long id)
    {
        return drawingMapper.deleteDrawingById(id);
    }

    /**
     * 获取待审核列表
     * @return
     */
    @Override
    public List<Drawing> getReviewList(Drawing drawing) {
        return drawingMapper.getReviewList(drawing);
    }

    /**
     * 获取图纸台账（通过审核）
     * @param drawing
     * @return
     */
    @Override
    public List<Drawing> getLedgerList(Drawing drawing) {
        return drawingMapper.getLedgerList(drawing);
    }

    /**
     * 获取历史图纸信息
     * @param historyId
     * @return
     */
    @Override
    public List<Drawing> getHistory(Long historyId) {
        return drawingMapper.getHistory(historyId);
    }


}
